<!DOCTYPE html>
<html>
  
<head>
    <title>
      编辑修改
    </title>

    <link href="http://fonts.googleapis.com/css?family=Lato:100,300,400,700" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/bootstrap.min.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/font-awesome.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/se7en-font.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/isotope.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/jquery.fancybox.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/fullcalendar.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/wizard.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/select2.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/morris.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/datatables.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/datepicker.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/timepicker.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/colorpicker.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/bootstrap-switch.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/daterange-picker.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/typeahead.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/summernote.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/pygments.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />
    <link href="/static/stylesheets/color/green.css" media="all" rel="alternate stylesheet" title="green-theme" type="text/css" />
    <link href="/static/stylesheets/color/orange.css" media="all" rel="alternate stylesheet" title="orange-theme" type="text/css" />
    <link href="/static/stylesheets/color/magenta.css" media="all" rel="alternate stylesheet" title="magenta-theme" type="text/css" />
    <link href="/static/stylesheets/color/gray.css" media="all" rel="alternate stylesheet" title="gray-theme" type="text/css" />

    <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js" type="text/javascript"></script>
    <script src="/static/javascripts/bootstrap.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/raphael.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/selectivizr-min.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.mousewheel.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.vmap.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.vmap.sampledata.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.vmap.world.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.bootstrap.wizard.js" type="text/javascript"></script>
    <script src="/static/javascripts/fullcalendar.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/gcal.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.dataTables.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/datatable-editable.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.easy-pie-chart.js" type="text/javascript"></script>
    <script src="/static/javascripts/excanvas.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.isotope.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/isotope_extras.js" type="text/javascript"></script>
    <script src="/static/javascripts/modernizr.custom.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.fancybox.pack.js" type="text/javascript"></script>
    <script src="/static/javascripts/select2.js" type="text/javascript"></script>
    <script src="/static/javascripts/styleswitcher.js" type="text/javascript"></script>
    <script src="/static/javascripts/wysiwyg.js" type="text/javascript"></script>
    <script src="/static/javascripts/summernote.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.inputmask.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.validate.js" type="text/javascript"></script>
    <script src="/static/javascripts/bootstrap-fileupload.js" type="text/javascript"></script>
    <script src="/static/javascripts/bootstrap-datepicker.js" type="text/javascript"></script>
    <script src="/static/javascripts/bootstrap-timepicker.js" type="text/javascript"></script>
    <script src="/static/javascripts/bootstrap-colorpicker.js" type="text/javascript"></script>
    <script src="/static/javascripts/bootstrap-switch.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/typeahead.js" type="text/javascript"></script>
    <script src="/static/javascripts/daterange-picker.js" type="text/javascript"></script>
    <script src="/static/javascripts/date.js" type="text/javascript"></script>
    <script src="/static/javascripts/morris.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/skycons.js" type="text/javascript"></script>
    <script src="/static/javascripts/fitvids.js" type="text/javascript"></script>
    <script src="/static/javascripts/jquery.sparkline.min.js" type="text/javascript"></script>
    <script src="/static/javascripts/main.js" type="text/javascript"></script>
    <script src="/static/javascripts/respond.js" type="text/javascript"></script>

    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
  </head>
  <body style="padding-top: 68px">
    <div class="modal-shiftfix">

      <!-- Navigation -->
        <div class="navbar navbar-fixed-top scroll-hide" style="height: auto;">
            <div class="container-fluid top-bar">
                <div class="pull-right">
                    <ul class="nav navbar-nav pull-right">
                        <li class="dropdown notifications hidden-xs">
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#"><span aria-hidden="true" class="se7en-flag"></span>
                                <div class="sr-only">
                                    Notifications
                                </div>
                            </a>
                            <ul class="dropdown-menu">
                                <li><a href="#">
                                    <div class="notifications label label-info">
                                        New
                                    </div>
                                    <p>
                                        New user added: Jane Smith
                                    </p></a>

                                </li>
                                <li><a href="#">
                                    <div class="notifications label label-info">
                                        New
                                    </div>
                                    <p>
                                        Sales targets available
                                    </p></a>

                                </li>
                                <li><a href="#">
                                    <div class="notifications label label-info">
                                        New
                                    </div>
                                    <p>
                                        New performance metric added
                                    </p></a>

                                </li>
                                <li><a href="#">
                                    <div class="notifications label label-info">
                                        New
                                    </div>
                                    <p>
                                        New growth data available
                                    </p></a>

                                </li>
                            </ul>
                        </li>
                        <li class="dropdown messages hidden-xs">
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#"><span aria-hidden="true" class="se7en-envelope"></span>
                                <div class="sr-only">
                                    Messages
                                </div>
                            </a>
                            <ul class="dropdown-menu messages">
                                <li><a href="#">
                                    <img width="34" height="34" src="/static/images/avatar-male2.png" />Could we meet today? I wanted...</a>
                                </li>
                                <li><a href="#">
                                    <img width="34" height="34" src="/static/images/avatar-female.png" />Important data needs your analysis...</a>
                                </li>
                                <li><a href="#">
                                    <img width="34" height="34" src="/static/images/avatar-male2.png" />Buy Se7en today, it's a great theme...</a>
                                </li>
                            </ul>
                        </li>
                        <li class="dropdown settings hidden-xs">
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#"><span aria-hidden="true" class="se7en-gear"></span>
                                <div class="sr-only">
                                    Settings
                                </div>
                            </a>
                            <ul class="dropdown-menu">
                                <li>
                                    <a class="settings-link blue" href="javascript:chooseStyle('none', 30)"><span></span>蓝</a>
                                </li>
                                <li>
                                    <a class="settings-link green" href="javascript:chooseStyle('green-theme', 30)"><span></span>绿</a>
                                </li>
                                <li>
                                    <a class="settings-link orange" href="javascript:chooseStyle('orange-theme', 30)"><span></span>橙</a>
                                </li>
                                <li>
                                    <a class="settings-link magenta" href="javascript:chooseStyle('magenta-theme', 30)"><span></span>品红</a>
                                </li>
                                <li>
                                    <a class="settings-link gray" href="javascript:chooseStyle('gray-theme', 30)"><span></span>灰</a>
                                </li>
                            </ul>
                        </li>
                        <li class="dropdown user hidden-xs"><a data-toggle="dropdown" class="dropdown-toggle" href="#">
                            <img width="34" height="34" src="/static/images/avatar-male.jpg" />Shinveam<b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li><a href="/article/gallery">
                                    <i class="icon-picture"></i>图片欣赏</a>
                                </li>
                                <li><a href="/article/chat" target="_blank">
                                    <i class="icon-comments"></i>和我聊天</a>
                                </li>
                                <li><a href="/article/404">
                                    <i class="icon-gear"></i>账号设置</a>
                                </li>
                                <li><a href="/article/exit">
                                    <i class="icon-signout"></i>退出</a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
                <button class="navbar-toggle">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="logo" href="/article/index">Shinveam</a>
                <form class="navbar-form form-inline col-lg-2 hidden-xs">
                    <input class="form-control" placeholder="Search" type="text">
                </form>
            </div>
        </div>
      <!-- End Navigation -->

      <div class="container-fluid main-content"><div class="page-title">
  <h1>
    修改文章
  </h1>
</div>

<div class="row">
  <div class="col-lg-12">
    <div class="widget-container fluid-height clearfix">
      <div class="heading">
        <i class="icon-reorder"></i>文章编辑
      </div>
      <div class="widget-content padded">
        <form onsubmit="return false" class="form-horizontal">
          <div class="form-group">
            <label class="control-label col-md-2">标题</label>
            <div class="col-md-7">
              <input class="form-control" value={{.article.ArtiName}} type="text" name="artiname" id="artiname">
            </div>
          </div>
         <div class="form-group">
            <label class="control-label col-md-2">分类</label>
            <div class="col-md-7">
              <select class="form-control">
                  <option >{{.article.ArticleType.TypeName}}</option>
              </select>
            </div>
          </div>

          <div class="form-group">
            <label class="control-label col-md-2">正文</label>
            <div class="col-md-7">
              <textarea class="form-control" rows="8" name="content" id="content">{{.article.Content}}</textarea>
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-2">是否修改</label>
            <div class="col-md-7">
              <button onclick="upload({{.article.Id}})" class="btn btn-primary" type="submit" >修改</button><button class="btn btn-default-outline">取消</button>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>

<div class="row">
  <div class="col-md-12">
    <div class="widget-container">
      <div class="heading">
        <i class="icon-cloud-upload"></i>上传图片
      </div>

      <div class="widget-content padded">
        <form onsubmit="return false" class="form-horizontal" enctype="multipart/form-data" method="post">
          <div class="form-group">
            <label class="control-label col-md-2">预览</label>
            <div class="col-md-4">
              <div class="fileupload fileupload-new" data-provides="fileupload">
                <div class="fileupload-new img-thumbnail" style="width: 200px; height: 150px;">
                    {{if .article.Img}}
                  <img src="/static/userImg/{{.article.Img}}">
                    {{end}}
                </div>
                <div class="fileupload-preview fileupload-exists img-thumbnail" style="width: 200px; max-height: 150px"></div>
                <div>
                  <span class="btn btn-default btn-file">
                      <span class="fileupload-new">更改图片？</span>
                      <span class="fileupload-exists">更改</span>
                      <input type="file" name="uploadImg" id="uploadimg">
                  </span>
                    <a class="btn btn-default fileupload-exists" data-dismiss="fileupload" href="#">移除</a>
                  <!--  <input type="submit" value="提交" onclick="upload()" >  -->
                </div>
              </div>
            </div>
          </div>
        </form>
      </div>

    </div>
  </div>
</div>

      </div>
    </div>
  </body>

<script>
    function doSubmit(filename, artiId){
        $.post("/article/revise",{
            "artiname":$("#artiname").val(),
            "content":$("#content").val(),
            "imgname":filename,
            "artiId" :artiId
        },function(resultData,statu){
            if(resultData=="failed"){
                alert("文章修改失败！");
            }else if(resultData=="success"){
                alert("修改成功");
                window.location.href="/article/index";
            }
        })

    }

    function upload(artiId){
        var formData=new FormData();
        formData.append('uploadImg', $("#uploadimg")[0].files[0]);  /*获取上传的图片对象*/

        if($('#uploadimg').val().length==0){
            if(!confirm("未选择文件，是否确认创建文章？")){
                return;
            }else{
                doSubmit("", artiId);
                return;
            }
        }

        var filename="";
        $.ajax({
            url: '/article/upload',
            type: 'POST',
            data: formData,
            contentType: false,
            processData: false,
            success: function (args) {
                if(args == "failed"){
                    if(!confirm("文件上传失败，是否继续创建文章？")){
                        return;
                    }
                }
                filename=args;
                doSubmit(filename,artiId);
            }});
    }
</script>


</html>